home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / Developer Documentation / Recipes, Tech Notes & Articles / Tech Notes / Utilities Documentation / Byte Arrays < prev    next >
Encoding:
Text File  |  1995-11-08  |  2.4 KB  |  68 lines  |  [TEXT/ttxt]

  1. OpenDocâ„¢ Utilities Documentation
  2.  
  3. Byte Array Utilities
  4. by The OpenDoc Design Team
  5.  
  6. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  7. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  8. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  9.  
  10.  
  11. Introduction
  12.  
  13. In order to be DSOM ready, OpenDoc uses ODByteArray (which is a sequence of octets) for varible length parameters. The ODByteArray utilities are used to manipulate these ODByteArray.
  14.  
  15. The utilities are written as procedural functions so that they can be used in both C and C++.
  16.  
  17. ODByteArray Utilities
  18.  
  19. Construction
  20.  
  21. Several functions are provided for construction of ODByteArray:
  22.  
  23.   ODByteArray* CreateByteArray(void* buffer, ODULong size);
  24.  
  25. Allocates an ODByteArray in the default heap and copies the buffer into the allocated ODByteArray.
  26.  
  27.  ODByteArray  CreateByteArrayStruct(void* buffer, ODULong size);
  28.  
  29. Allocates an ODByteArray on the stack and copies the buffer into the allocated ODByteArray.
  30.  
  31.  ODByteArray* CreateEmptyByteArray(ODULong maximum);
  32.  
  33. Allocates an ODByteArray in the default heap with a buffer of the specified size.
  34.  
  35.  ODByteArray  CreateEmptyByteArrayStruct(ODULong maximum);
  36.  
  37. Allocates an ODByteArray on the stack with a buffer of the specified size.
  38.  
  39. Destruction
  40.  
  41. void   DisposeByteArray(ODByteArray* array);
  42.  
  43. Deallocates both the buffer and the structure of the ODByteArray. The ODByteArray must be allocated in the default heap.
  44.  
  45. void DisposeByteArrayStruct(ODByteArray* array);
  46.  
  47. Deallocates the buffer allocated in CreateEmptyByteArrayStruct and CreateByteArrayStruct. The struct itself is deallocated from the stack when the caller function exits its scope.
  48.  
  49. Modification
  50.  
  51.  void UseByteArray(ODByteArray* ba, void* buffer, ODULong size);
  52.  
  53. Given an ODByteArray struct, put the pointer to the buffer and size into the appropriate fields. If the ODByteArray contains other values, they will be overwritten by the new values.
  54.  
  55. Duplication
  56.  
  57. ODByteArray* CopyByteArray(ODByteArray* fromBA);
  58.  
  59. Allocates an ODByteArray in the default heap and copies the buffer from the specified ODByteArray to the new one.
  60.  ODByteArray  CopyByteArrayStruct(ODByteArray* fromBA);
  61.  
  62. Allocates an ODByteArray on the stack and copies the buffer from the specified ODByteArray to the new one.
  63.  
  64. Comparision
  65.  
  66.  ODBoolean  AreByteArraysEqual(ODByteArray* ba1, ODByteArray* ba2);
  67.  
  68. Returns kODTrue if the buffers in the two specified ODByteArrays match. Otherwise, returns kODFalse.